<template>
  <div>
    <div class="aui-he"></div>
    <div class="aui-content aui-margin-b-15">
      <ul class="aui-list aui-form-list">
        <template v-for="(item, index) in form_item">
          <li class="aui-list-item" :key="item.prop">
            <div class="aui-list-item-inner">
              <div class="aui-list-item-label-icon">
                <i :class="['aui-iconfont', 'aui-icon-' + item.icon]"></i>
              </div>
              <div class="aui-list-item-input">
                <input
                  :type="item.type"
                  :placeholder="item.placeholder"
                  v-model="form_data[item.prop]"
                />
              </div>
              <div
                @click="changeType(index)"
                class="aui-list-item-label-icon"
                v-if="item.prop === 'password'"
              >
                <i class="aui-iconfont aui-icon-display"></i>
              </div>
            </div>
          </li>
        </template>
        <div class="aui-padded-15 aui-text-right">
         <router-link v-if="$route.name=='login'" :to="{path:'/register'}">没有账号？去注册</router-link>
         <router-link v-if="$route.name=='register'" :to="{path:'/login'}">已有账号？去登录</router-link>
        </div>
        <div class="aui-padded-15 aui-text-center">
          <div
            @click="submit"
            class="aui-btn aui-btn-block aui-btn-sm aui-btn-danger"
          >
            {{ $route.name == "login" ? "登录" : "立即注册" }}
          </div>
        </div>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    form_data: {
      type: Object,
      default: () => {},
    },
    form_item: {
      type: Array,
      default: () => [],
    },
  },
  methods: {
    changeType(index) {
      this.$emit("changeType", index);
    },
    submit() {
      this.$emit("submit", this.form_data);
    },
  },
};
</script>

<style>
</style>